def copy_file(src,dest):
    #使用了with之后就不用在进行close了，系统会自动关闭
    with open(src,'rb') as sfile:
        with open(dest,'wb')as dfile:
            for data in sfile.readlines():
                dfile.write(data)
#此时不用写close
copy_file('a.txt','b.txt')
